﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 委托02
{
    public delegate void Kid();

    class Program
    {
        static void Main(string[] args)
        {
            Boss boss = new Boss();
            Kid kid = new Kid(boss.Robe);

            // 委托链
            kid += boss.Kill;
            kid += boss.Fire;

            kid -= boss.Robe;
            kid -= boss.Kill;
            kid -= boss.Fire;

            //kid();

            if (kid != null)
            {
                kid();
            }
        }
    }

    class Boss
    {
        public void Fire()
        {
            Console.WriteLine("放火...");
        }
        public void Kill()
        {
            Console.WriteLine("砍他...");
        }
        public void Robe()
        {
            Console.WriteLine("抢劫了，把钱交出来...");
        }
    }
}
